﻿@using Pay.DTO;
@using Pay.Core;
@{
    ViewBag.Title = "我的银行卡";
    Layout = "~/Views/Shared/_MallLayout.cshtml";
    var myBankCard = ViewBag.MyBankCard as api_merchant_bank_card_dto;
    var bankList = ViewBag.BankList as List<DropdownItem>;

}
<body class="page-bank">
    <form id="myform" name="myform" enctype="multipart/form-data" method="post" action="@Url.Action("AddOrUpdateBankCard","MerchantBankCard")">
        <input type="hidden" id="id" name="id" value="@myBankCard.id" />
        <input type="hidden" id="hand_id_card_img" name="hand_id_card_img" value="@myBankCard.hand_id_card_img" />
        <div class="mod-forms">
            <div class="ui-item">
                <div class="ui-label">开户名</div>
                <div class="ui-hidden">
                    <input type="text" id="account_name" name="account_name" value="@myBankCard.account_name" class="ui-input" placeholder="请输入开户名">
                </div>
            </div>
            <div class="ui-item">
                <div class="ui-label">银行卡号</div>
                <div class="ui-hidden">
                    <input type="text" id="account_num" name="account_num" value="@myBankCard.account_num" class="ui-input" placeholder="请输入银行卡号"
                           onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                           onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^0-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                </div>
            </div>
            <div class="ui-item">
                <div class="ui-label">银行名称</div>
                <div class="ui-hidden">
                    <select class="ui-select" name="bank_name" id="bank_name">
                        @if (bankList != null && bankList.Count() > 0) {
                            foreach (var bank in bankList) {
                                <option value="@bank.Text" @((myBankCard.id > 0 && myBankCard.bank_name == bank.Text ? "selected=\"selected\"" : ""))>@bank.Text</option>
                            }
                        }
                    </select>
                </div>
            </div>
            <div class="ui-item">
                <div class="ui-label">开户支行名称</div>
                <div class="ui-hidden">
                    <input type="text" id="branch_name" name="branch_name" value="@myBankCard.branch_name" class="ui-input" placeholder="请输入开户支行名称">
                </div>
            </div>
            <div class="btnBox">
                <a href="javascript:submitBankBaseInfo()" class="ui-btn-buy">提 交</a>
            </div>
        </div>
    </form>
</body>


<script type="text/javascript">
    function submitBankBaseInfo() {
        var flag = true;
        $("#myform .ui-input").each(function (index, el) {
            if ($(el).val() == undefined || $(el).val() == '') {
                flag = false;
                layer.msg($(el).attr('placeholder'));
                return false;
            }
        })
        if (!flag)
            return flag;

        @*window.location.href = '@Url.Action("UploadHandIdCardImg", "MerchantBankCard")?' + $("#myform").serialize();*@
        $("#myform").ajaxSubmit(function (result) {
            if (result.result_code == 1000) {
                layer.msg(result.result_msg);
                setTimeout(function () { window.location.href = '@Url.Action("MyBankCard", "MerchantBankCard")';}, 1500);
            } else {
                layer.msg(result.result_msg);
            }
        });
    }


</script>

